﻿using System;
using System.Web.Mvc;

public class CustomExceptionFilter : FilterAttribute, IExceptionFilter
{
    public void OnException(ExceptionContext filterContext)
    {
        if (filterContext.ExceptionHandled)
            return;

        // 记录日志（可选）
        // LogHelper.Log(filterContext.Exception);

        // 设置为已处理
        filterContext.ExceptionHandled = true;

        // 设置跳转路径
        filterContext.Result = new ViewResult
        {
            ViewName = "Error",
            ViewData = new ViewDataDictionary(new { ErrorMessage = filterContext.Exception.Message })
        };
    }
}